package com.ssy.lingxi.report.serviceimpl.tally;

import com.ssy.lingxi.report.service.IContractReportService;
import com.ssy.lingxi.report.service.IMemberReportService;
import com.ssy.lingxi.report.service.tally.ITallyReportDataInitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 进行初始化统计 serviceImpl
 */
@Service
public class TallyReportDataInitServiceImpl implements ITallyReportDataInitService {


    private static final Logger logger = LoggerFactory.getLogger(TallyReportDataInitServiceImpl.class);

    @Resource
    private IContractReportService contractReportService;
    @Resource
    private IMemberReportService memberReportService;

    @Override
    public void initStatisticsData() {
        logger.info("历史数据初始化统计开始>>>");

        initPlatformPurchaseData();

        initPortalPurchaseData();

        logger.info("历史数据初始化统计结束>>>");
    }

    private void initPlatformPurchaseData(){
        logger.info("初始化平台采购统计数据");
        try {
            contractReportService.initContractDayReport();
        }catch (Exception e){
            logger.error("初始化平台采购统计数据异常：",e);
        }

        logger.info("初始化平台采购统计数据完成");
    }

    private void initPortalPurchaseData(){
        logger.info("初始化采购门户统计数据");
        try {
            memberReportService.initPurchaseDayReport();
        }catch (Exception e){
            logger.error("初始化采购门户统计数据异常：",e);
        }
        logger.info("初始化采购门户统计数据完成");
    }
}
